<template>
  <div v-if="user" class="my-qrcode">
    <div class="code">
      <qrcode-vue :value="`u:${user.id}:${user.code}:${user.wallet}:${user.phone}`" level="H" :size="200"></qrcode-vue>
      <div class="my-wallet van-hairline--top">
        我的余额：<span class="hl-price">{{ user.wallet }}元</span>
      </div>
    </div>
  </div>
</template>
<script>
import QrcodeVue from 'qrcode.vue'
// import { mapState } from 'vuex'
import { GetUser } from '../api/user'
export default {
  components: { QrcodeVue },
  data() {
    return {
      user: null
    }
  },
  // computed: mapState(['user'])
  created() {
    GetUser()
      .then(res => {
        this.user = res
      })
      .catch(err => {
        this.$toast(err)
      })
  }
}
</script>
<style lang="less" scoped>
.my-qrcode {
  // height: 100vh;
  height: 100%;
  box-sizing: border-box;
  padding: 16px;
  background-color: #429056;
  display: flex;
  align-items: center;
  justify-content: center;
  .code {
    padding: 16px;
    background-color: #fff;
  }
  .my-wallet {
    margin-top: 8px;
    padding-top: 8px;
    span {
      float: right;
    }
  }
}
</style>
